<?php
class ControllerSaleCustomerIp extends AdminController {
	
	public function index() {
		M('sale/customer_ip', 'mod_ip');
		$this->getList();		
	}
	
	public function clear() {
		M('sale/customer_ip', 'mod_ip');
		if ($this->hasMP()) {
			if ($this->mod_ip->clearCustomerIps()) {
				$this->session->set_flashdata('success', $this->_['text_success']);
				$this->redirect(UA('sale/customer_ip'));
			}
		}
		else {
			$this->setMessage('error_warning', $this->_['error_permission']);
		}
		$this->getList();
	}
	
	protected function getList() {
		$qf = new Query_filter();
		
		$total = $this->mod_ip->getTotalCustomerIps($qf);
		$this->data['ips'] = $this->mod_ip->getCustomerIps($qf);
		
		$this->data['pagination'] = $this->pagination($total)->render();
		
		$this->data['filter_customer_id'] = $qf->get('filter_customer_id');
		$this->data['filter_email'] = $qf->get('filter_email');
		$this->data['filter_ip'] = $qf->get('filter_ip');
		$this->data['filter_date_added'] = $qf->get('filter_date_added');
		
		$this->display('sale/customer_ip_list.tpl');
	}
}